home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / GAME_CGA / CRIBBAGE.LZH / HALSCRIB.TXT < prev    next >
Text File  |  1987-10-10  |  17KB  |  463 lines

  1.  
  2.  
  3.  
  4.      HALSCRIB       (c)  1987      Hal Mueller    Page 1 of 7
  5.  
  6. The paper consists of the following sections:
  7.  
  8.      1.   Overview and approach of other computerized classic games
  9.  
  10.      2.   Elements and Rules of Cribbage
  11.  
  12.      3.   Optimal Strategy selection and deviation therefrom 
  13.           employed during a game by the computer and the human 
  14.           opponent
  15.  
  16.      4.   Preliminary results against human opponents of varying 
  17.           skill levels
  18.  
  19.      5.   Summary and Conclusions 
  20.  
  21.      6.   Further Research
  22.  
  23.  
  24. 1.   Other Computerized Classic Games
  25.  
  26.      A   number  of  2-person  zero-sum  games  can  be   broadly 
  27.      classified into those where 
  28.  
  29.      i.   all information is available to both players
  30.  
  31.      ii.  some information is available to both players
  32.  
  33.      iii. the element of chance plays no role whatsoever
  34.  
  35.      iv.  the element of chance plays some role in the outcome
  36.  
  37.      v.   the margin of victory may double the winner's payoff
  38.  
  39. Games such as CHESS, GO, and REVERSI/OTHELLO belong to categories 
  40. i. and iii.  
  41.  
  42. POKER belongs to ii and iv.
  43.  
  44. BACKGAMMON belongs to categories i, iv, and v.
  45.  
  46. CRIBBAGE and DOMINOES belong to categories ii, iv, and v.
  47.  
  48. Typical  move  selection  heuristics for  Chess-playing  programs 
  49. include  mini-max search (including alpha-beta  pruning),  search 
  50. for  "killer"  moves,   and  iterative  deepening  based  on   an 
  51. evaluation   function.    The  depth  and  width  of  the  search 
  52. materially affect the strength of the program.
  53.  
  54. In  Go,  the size of the search tree precludes the approach taken 
  55. in  Chess.    Pattern-matching  heuristics  in  conjunction  with 
  56. massive  parallel processing probably will result  in  GO-playing 
  57. programs that approach that of a human expert.
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      HALSCRIB       (c)  1987      Hal Mueller    Page 2 of 7
  71.  
  72. Work  done in computer Poker indicates a weakness on the reliance 
  73. on  expectations  and the use of measurements of  the  opponents' 
  74. past  performance  for judging "Bluffing"  situations.   Programs 
  75. written   by   Findler  et  al  implemented   different   playing 
  76. strategies,  Mathematically Fair (static strategy - decides  when 
  77. and  what to bet by equating expected values of wins and losses - 
  78. bets  strictly  according  to  the  odds),   Statistically   Fair 
  79. (dynamic strategy - includes a learning component that identifies 
  80. opponents' extent and frequency of bluffing),  and several others 
  81. (RH Player,  Bayesian Player,  Pattern Recognition Player, Advice 
  82. Taker and Inquirer, Quasi-Optimizer Player, etc).
  83.  
  84. Backgammon programs by H.   Berliner,  Carnegie-Mellon, utilize a 
  85. smoothing  approach to  strategy variation  as  dictated  by  the 
  86. relative  status  of the  players' remaining men.   He classified
  87. different  backgammon  positions such that the  evaluation  space 
  88. provided  for  increased importance of particular  features.   He 
  89. controlled  these  transitions (dependent on  other  features  as 
  90. well)   by  "application  coefficients"  which  vary  slowly  and 
  91. smoothly  avoiding the rough boundaries which exist  between  the 
  92. different classified positions.   (This approach is called  SNAC, 
  93. for smoothness, nonlinearity, and application coefficients).
  94.  
  95. Most  Cribbage  games encountered by the author follow  a  static 
  96. strategy  based on heuristics,  regardless of the relative status 
  97. of  the players' scores.   During the selection of the  discards, 
  98. and  the play of the hands,  several opportunities exist to  vary 
  99. strategical decisions.
  100.  
  101.  
  102. 2.   Elements and Rules of Cribbage
  103.  
  104. Cribbage  is one of the most enjoyable card games ever  developed 
  105. for  two  players.   Not only  does it provide scope for informed
  106. strategic  decisions,  but also offers numerous ways of  scoring, 
  107. both in the play and in the count of the hands and crib.
  108.  
  109. Initially,  an  ordinary  deck of 52 playing cards  is  shuffled.  
  110. Each  player  "cuts"  the  deck,  exposing  a  card.   By  mutual 
  111. agreement beforehand, the player cutting the lower (or higher) is 
  112. designated  as  the  "dealer"  for  the  first  deal.   The  deal 
  113. alternates afterwards.
  114.  
  115. The  dealer shuffles the deck randomly and then deals  six  cards 
  116. alternately,  one  at  a time,  face down to  each  player.   The 
  117. players  examine  their  hands,  and decide which  two  cards  to 
  118. discard  face down in the crib.   The crib belongs to the dealer.  
  119.  
  120. After  the crib has been formed,  the non-dealer cuts the  cards.  
  121. The  dealer  then  turns face up the top card of the  lower  deck 
  122. which  is then placed on top of the deck.   This top card is  the 
  123. up-card (or "starter").  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      HALSCRIB       (c)  1987      Hal Mueller    Page 3 of 7
  137.  
  138. The remaining four cards are retained and become revealed  during 
  139. the  play.   The non-dealer begins the play by laying out one  of 
  140. his cards face up and announcing its value.   (Aces are 1,  face-
  141. cards  are all 10,  remaining cards have a value equal  to  their 
  142. pip-value).  The dealer then lays out a card in the same fashion, 
  143. but  announces the cumulative sum - previous cumulative sum  plus 
  144. the value of his card.
  145.  
  146. The  play  alternates until the cumulative sum is 31  or  neither 
  147. player can play a card without exceeding 31.   The cumulative sum 
  148. is  reset to 0 and play commences as before until all four  cards 
  149. have been layed out by both players.
  150.  
  151. During  the  play either player can score points in a  number  of 
  152. ways.   This  process  of obtaining points is  called  "pegging".  
  153. After the hand has been played, the non-dealer computes the value 
  154. of  his  hand  in   conjunction with the  up-card  which  can  be 
  155. included  in the evaluation of each player's hand as well as  the 
  156. crib.   
  157.  
  158. After  the non-dealer has scored his hand,  the dealer scores his 
  159. hand  and then his crib.   The first player to reach  121  points 
  160. wins  the game.   If the other player has less than 91 points but 
  161. more than 60,  the value of the game is doubled  ("skunked"),  or 
  162. the  loser  has  less  than 61 points the value of  the  game  is 
  163. quadrupled ("double-skunk").
  164.  
  165. Points  can  be  scored in a number of ways,  some of  which  are 
  166. similar to the way in which points during pegging may be scored.
  167.  
  168.  
  169. Scoring During Pegging:
  170.  
  171. 15 or 31:
  172.  
  173. If  a  player makes the cumulative sum = 15 or =  31,  then  that 
  174. player pegs 2 points (increases his score by 2).
  175.  
  176.  
  177. Pairs:
  178.  
  179. If  a  player plays a card of the same rank as the last  one  (in 
  180. play), then that player pegs 2 points.  
  181.  
  182. If,  after  a pair has been made,  a card of the same rank can be 
  183. legally  played,  then  that player pegs 6  points  (3-of-a-kind, 
  184. triplets, or Pairs Royal).
  185.  
  186. If,  after a 3-of-a-kind has been made,  a card of the same  rank 
  187. can  be legally played,  then that player pegs 12 points (4-of-a-
  188. kind,  double pairs,  or double Pairs Royal).   (Can only  happen 
  189. with cards whose rank is 7 or less.)
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.      HALSCRIB       (c)  1987      Hal Mueller    Page 4 of 7
  203.  
  204. Sequences or Runs:
  205.  
  206. If  3  or  more cards in uninterrupted  numerical  sequence,  not 
  207. necessarily  of  the  same  suit  nor  in  strict  ascending   or 
  208. descending  sequence  - eg  3-4-2-5  but not  3-4-6-2  have  been 
  209. played, the player who completed the run or sequence pegs 1 point 
  210. for  each  card  in the uninterrupted  sequence.   In  the  first 
  211. example  the player who played the 2 pegs 3 points (run of 3) and 
  212. the player who played the 5 pegs 4 points (run of 4).  Whereas in 
  213. the  second example there are no runs at all,  but the player  on 
  214. turn could peg 5 points by playing a 5 (run of 5).  
  215.  
  216.  
  217. Last-card or Go:
  218.  
  219. If  a  player  on turn is unable to  play  another  card  without 
  220. exceeding 31, he says Go and the other player must go on playing, 
  221. if  he  can,  until  he reaches 31 or can not play  another  card 
  222. without  exceeding 31 himself.  If he is also unable to play,  he 
  223. also announces Go and pegs 1 point.   The last card played scores 
  224. 1  point unless it makes the cumulative sum = 31,  in which  case 
  225. only 2 points are pegged.
  226.  
  227.  
  228. Scoring of Hands and Crib:
  229.  
  230. After pegging has been completed, the non-dealer places his cards 
  231. face  up and counts his hand including the up-card and  makes  as 
  232. many  scoring combinations of  15's,  pairs,  runs,  flushes,  as 
  233. possible.
  234.  
  235. 15's:
  236.  
  237. Every  combination  of cards (with or without the  up-card)  that 
  238. totals 15 scores 2 points.
  239.  
  240.  
  241. Pairs:
  242.  
  243. Every combination of cards that forms a pair (with or without the 
  244. up-card) scores 2 points.
  245.  
  246.  
  247. Runs:
  248.  
  249. Every  combination  of cards (with or without the  up-card)  that 
  250. forms a run of 3 or more,  regardless of suit, scores 1 point for 
  251. each card in the run.
  252.  
  253.  
  254. Flushes:
  255.  
  256. Four cards of the same suit in the hand or all cards of the  same 
  257. suit  as  the  up-card scores 1 point for each card of  the  same 
  258. suit.  (Score is 4 or 5).
  259.  
  260. However, the crib must have all cards of the same suit as the up-
  261. card to score 5.  (Score of 4 is not possible.)
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.      HALSCRIB       (c)  1987      Hal Mueller    Page 5 of 7
  269.  
  270.  
  271. His Nibs (His Nobs, Jack-in-the-Hand or Crib):
  272.  
  273. One point is scored for having a Jack in the hand or  in the crib
  274. of the same suit as the up-card.
  275.  
  276.  
  277. Up-card:
  278.  
  279. If  a Jack is the Up-card,  the dealer pegs 2 points  immediately 
  280. after the cut has been made.
  281.  
  282.  
  283. Optimal Strategy Selection
  284.  
  285. Hand Selection from 6 Dealt
  286.  
  287. There  are 15 different combinations of 4 cards (to be  retained  in
  288. the hand) and 2 cards (to be discarded into the crib).
  289.  
  290. The program decides which of 7 different strategies it should adopt:
  291.      max of 4-card scores (ignoring up-card and crib)
  292.      max of max best 5-card score - min crib | dealer is opp
  293.      max of max best 5-card score + max crib | dealer is comp
  294.      max of expected 5-card score - expected crib | dealer is opp
  295.      max of expected 5-card score + expected crib | dealer is comp 
  296.      max of expected 5-card score - max crib | dealer is opp
  297.      max of expected 5-card score + expected crib | dealer is comp
  298.  
  299. The strategy selected is dependent on the score and the deal.
  300.  
  301. Whenever  the  difference in score between the two players  is  less
  302. than 16,  the strategy it adopts is the "optimal" (expected hand and
  303. expected  crib  are utilized).   This strategy is "optimal"  in  the
  304. sense that the player will maximize his points,  on average,  over a
  305. large number of plays of a particular holding.
  306.  
  307. If it is behind by more than 15 points it adopts a "risky" strategy.
  308. (Chooses  max of best 5-card hand + max crib or - min  crib).   This
  309. strategy  is  risky  because  it  depends  on  obtaining  the   most
  310. favourable up-card.  This up-card would not, in general, be the most
  311. likely.
  312.  
  313. If  it is ahead by more than 15 points it adopts a "safe"  strategy.
  314. (Chooses  max of expected hand + expected crib or - max  crib).   If
  315. the  computer is the dealer,  its strategy is similar to the optimal
  316. strategy (ties are broken differently).  However, if the opponent is
  317. the dealer, then it will choose its discards so as to minimize their
  318. benefit to the opponent given the most undesirable up-card.   Again,
  319. this unfavourable up-card would not, in general, be the most likely.
  320.  
  321. If it can reach game, it adopts a "safe" strategy.  
  322.  
  323. If the opponent counts first and is expected to reach 121,  then  it
  324. adopts a "risky" strategy.   
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.      HALSCRIB       (c)  1987      Hal Mueller    Page 6 of 7
  335.  
  336. If  it counts first and the opponent is expected to reach 121,  then
  337. it adopts a "safe" strategy if it has less than 91 and can exceed 90
  338. based  on its hand (to avoid a skunk) and similarly if it  has  less
  339. than 61 and can exceed 60  (to avoid a double-skunk).
  340.  
  341. If  it  expects to reach game and the opponent counts first and  has
  342. less than 91 (or 61) and expects the opponent to avoid the skunk (or
  343. double-skunk), then it adopts a "risky" strategy.
  344.  
  345. During the play of the hand,  the current point differential is used
  346. in selecting its strategy: safe, optimal, risky.
  347.  
  348. For  each  possible legal card,  it evaluates the  expected  pegging
  349. score  (using  current  probabilities),  the  maximum  possible  net
  350. pegging  score  (ignoring probabilities),  and the maximum  possible
  351. opponent  pegging  score  (ignoring  probabilities).    The  optimal
  352. strategy selects the max expected pegging score.   The safe strategy
  353. selects  the min of opponent max pegging score.   The risky strategy
  354. selects the max of net pegging score.
  355.  
  356. If it is on lead and there is no pair in its holding, it will select
  357. that card which maximizes its expected value.   If there is a  pair,
  358. the  expected value of always leading a card from a pair is  greater
  359. than  from  any non-pair card playing against an unbiased  opponent.
  360. Because a human opponent can easily detect this bias, it will forego
  361. the mathematically  sound play of the pair and choose an  "inferior"
  362. card  between 50-80% of the time.    (The percentage is dependent on
  363. the  point  differential).  Similarly,  if it is on play  after  the
  364. opening lead,  it will select that card which maximizes its expected
  365. value.   Because  a  bias in always pairing if possible also can  be
  366. detected easily,  it will forego the mathematically optimum play and
  367. select an "inferior" card between 35-65% of the time.
  368.  
  369. These  percentages were derived from the following "Pay-off  Matrix"
  370. and then adjusted to reflect actual frequencies of applicability.
  371.              Table I (simplistic)      Table II (probabilistic)
  372.          ||   4  -2 ||             ||  .40   -.23 ||
  373.          ||  -2   2 ||             || -.25    .24 ||
  374. Optimal  strategy is to lead a pair 40% (44%) of the time - pair the
  375. first  card 40% (42%) of the time.    These ratios are  adjusted  to
  376. allow  for  those  situations when no choice is  possible  (no  pair
  377. available to lead - no card available to pair).
  378.  
  379.  
  380.  
  381. Preliminary Results
  382.  
  383. During  the  initial  trials  of  the  program  against  myself  and
  384. knowledgable cribbage players,  it became obvious that when on  lead
  385. it  invariably  led  from  a small pair  whenever  it  could.   This
  386. selection is optimal if there is no bias in the play of its opponent
  387. or  if the opponent also plays in  "optimal"  fashion.   However,  a
  388. human  opponent  can take advantage of this prediliction  and  avoid
  389. pairing  cards  immediately  at  some slight  risk  of  not  pegging
  390. anything  or  being paired by the computer later in the play of  the
  391. hand.
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.      HALSCRIB       (c)  1987      Hal Mueller    Page 7 of 7
  401.  
  402. A change was made whereby it deviated from the  (biased) optimum, so
  403. that when it had a pair,  it made that selection 65% of the time  in
  404. "optimal" situations,  80% of the time in "safe" situations, and 50%
  405. of the time in "risky" situations.  (In "safe" situations, a pair by
  406. the  risk-taking opponent would allow it to increase its lead.)  (In
  407. "risky" situations, a cautious opponent would avoid pairing so as to
  408. avoid having the computer peg 6 for 3-of-a-kind.   It would increase
  409. the possibility of it pairing its own card later in the play.) 
  410.  
  411.  
  412. This  made  the  computer  far  less  predictable  and  consequently
  413. increased its playing strength. 
  414.  
  415.                Cumulative tally:
  416.  
  417.            Before (biased optimum)   -  20 wins by computer
  418.                                         31 wins by opponents
  419.  
  420.            After (unbiased optimum)  -  72 wins by computer
  421.                                         53 wins by opponents
  422.  
  423.  
  424. Summary and Conclusions
  425.  
  426. Cribbage is a game where a knowledge of permutations and combinations
  427. is   essential  to  optimal play.    A knowledge of  the  predictable
  428. playing  style  of the opponent can materially affect the outcome  of
  429. an  extended series of games.
  430.  
  431.  
  432. Further Research
  433.  
  434. At present, the program adopts a "static" statistically optimum mixed
  435. strategy  when leading and pairing (see Pay-off Matrix)  against  all
  436. opponents.    The next step is  to monitor the pegging-style of  each
  437. opponent  and  adjust its own pegging-style  ratios  accordingly.  In
  438. addition, it should use  current probabilities in computing the value
  439. of the pay-off matrix entries.   The result would be a "dynamic" sta-
  440. tistical  optimal  mixed  strategy  for the initial lead  or  initial
  441. response to the opening lead.
  442.                                     
  443. How  this  program  would fare against an opponent who  uses  "pure"
  444. strategies only or against a "static" statistical mixed strategy  in
  445. a match of 15 games would be interesting.
  446.  
  447.  
  448.  
  449. BIBLIOGRAPHY and REFERENCES
  450.  
  451. Anderson, Douglas, All About Cribbage, Winchester Press, NYC, 1971
  452.  
  453. Berliner, Hans, Computer Backgammon, Scientific American June 1980
  454.  
  455. Findler, Nicholas V., Computer Poker, Scientific American July 1978
  456.  
  457. Levy, David, Computer Gamesmanship, Century Publishing, London, 1983
  458.  
  459.  
  460.  
  461.  
  462.  
  463.